using UnityEngine;
using System.Collections;



public class LoadingUIHandler : GameUIHandler< LoadingUIHandler >
{

	AsyncOperation async = null;


	void Awake ()
	{
		mInstance = this;
	}
	
	public override void onRelease()
	{
//		UITexture _newTexture = NGUITools.AddWidget< UITexture >(gameObject);
//		_newTexture.pivot = UIWidget.Pivot.TopLeft;
//		_newTexture.material = new Material(Shader.Find("Unlit/Transparent Colored with mask"));
//		_newTexture.mainTexture = myTexture2D;
//		_newTexture.MakePixelPerfect();
//		
//		//now we give the shader the textures
//		
//		_newTexture.material.SetTexture(<wbr />"_MainTex", testRed);
//		_newTexture.material.SetTexture(<wbr />"_AlphaTex", testAlpha);
	}
	public override void onInit()
	{
		
	}
	public override void onOpen()
	{

	}
	public override void onClose()
	{
		
	}

	public void loadScene( int s )
	{
		//Application.LoadLevel( 1 );

		StartCoroutine( loadSceneCoroutine( s ) );
	}

	IEnumerator loadSceneCoroutine( int s )
	{
		async = Application.LoadLevelAsync( s );

		yield return async;
	}


	// Use this for initialization
	void Start () 
	{
		//Show();
	}

	
	// Update is called once per frame
	void Update () 
	{
		if ( async != null )
		{
			if ( async.progress == 1 && LoadingUIHandler.instance != null )
			{
				UnShow();
				
				async = null;
			}
		}

	}

}
